import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: '',
    showMasker: false,
    urlParams: {
      uniacid: '',
      type: '',
      share_uid: ''
    },
    userinfo: {},
    isShowCodeDialog: false,
  },
  mutations: {
  	SET_PAGE_TITLE(state, title){
  		state.pageTitle = title;
  	},
  	SET_SUBLINK(state, sublink){
  		state.sublink = sublink;
  	},
    SET_DRIVER_STATUS(state, isDriver){
      state.isDriver = isDriver;
    },
    SET_TOKEN(state, token){
      state.token = token;
    },
    SET_MASKER_DISPLAY(state, show){
      state.showMasker = show;
    },
    SET_URL_PARAMS(state, urlParams){
      state.urlParams = urlParams;
    },
    SET_USER_INFO(state, userinfo){
      state.userinfo = userinfo;
    },
    SET_CODE_DIALOG_STATUS(state, staus){
      state.isShowCodeDialog = staus;
    }
  },

  actions: {
  	setPageTitle({ commit }, title){
		commit('SET_PAGE_TITLE', title);
  	},
  	setSublink({ commit }, sublink){
  		commit('SET_SUBLINK', sublink);
  	},
    setDriverStatus({ commit }, isDriver){
      commit('SET_DRIVER_STATUS', isDriver);
    },
    setToken({ commit }, token){
      commit('SET_TOKEN', token);
    },
    setMaskerDisplay({ commit }, show){
      commit('SET_MASKER_DISPLAY', show);
    },
    setParams({commit}, urlParams){
      commit('SET_URL_PARAMS', urlParams);
    },
    setUserinfo({commit}, userinfo){
      commit('SET_USER_INFO', userinfo);
    },
    setCodeDialogStatus({commit}, status){
      commit('SET_CODE_DIALOG_STATUS', status)
    }
  }
})
